﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Box2D.XNA;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using ElementumForever.Utility;
using LuaInterface;
using Microsoft.Xna.Framework.Input;
using ElementumForever.Interfaces;
using ElementumForever.Factory;
using ElementumForever.Enums;

namespace ElementumForever
{
    public class RectangleShape : PrimitiveShape
    {

        public RectangleShape()
        {
            this.ObjectClass = EObjectClass.rectangle;
        }

        public override void OnCreat()
        {
            base.OnCreat();
            _renderTarget2D = new RenderTarget2D(MainGame.GetGraphicsDevice(), 1, 1);//1*1
            _renderTarget2D.SetData(new[] { Color.White });
        }

        public override Box2D.XNA.Shape ConventToBox2DShape()
        {
            PolygonShape bShape = new PolygonShape();
            bShape.SetAsBox(Width / 2 / PhysicalFactory.PixelToMeter, Height / 2 / PhysicalFactory.PixelToMeter);
            return bShape;
            throw new NotImplementedException();
        }

        public override void OnUpdate(GameTime gameTime)
        {
            base.OnUpdate(gameTime);
        }


        public override IEntity Clone()
        {
            return new RectangleShape();
        }

        protected override void Draw(GameTime gameTime, SpriteBatch spriteBatch)
        {
            Vector2 size = new Vector2(Width, Height);
            spriteBatch.Draw(_renderTarget2D, Vector2.Zero, null, this.Color, 0, Vector2.Zero, size, SpriteEffects.None, LayerDepth);
        }
    }

}
